Skip to content

feat(backend,testing): Add agent tasks endpoints & helpers#7783

Merged
tmilewski merged 11 commits intomainfrom
tom/user-4622-implement-utt-backend-sdk-endpoints
Feb 20, 2026
Merged

feat(backend,testing): Add agent tasks endpoints & helpers#7783
tmilewski merged 11 commits intomainfrom
tom/user-4622-implement-utt-backend-sdk-endpoints

Conversation

@tmilewski
Copy link
Member

@tmilewski tmilewski commented Feb 5, 2026

Description

Adds support for the Agent Tasks API endpoint to the backend SDK. This allows developers to create agent tasks that can be used to act on behalf of users during testing or other automated flows.

Usage

import { createBackendApiClient } from '@clerk/backend';

const client = createBackendApiClient({ secretKey: 'sk_test_...' });

// Create an agent task
const agentTask = await client.agentTasks.create({
  onBehalfOf: {
    userId: 'user_xxx',
  },
  permissions: '*',
  redirectUrl: '...',
});

console.log(agentTask.url);
import { createAgentTestingTask } from '@clerk/testing/playwright';
import { expect, test } from './base';

test.describe('Logged In State', () => {
  test('should display logged in message', async ({ page }) => {
    const userId = process.env.CLERK_TEST_USER_ID!;

    const { url } = await createAgentTestingTask({
      // secretKey: process.env.CLERK_SECRET_KEY!, // Optional, inferred otherwise
      onBehalfOf: {
        userId,
      },
      permissions: '*',
      agentName: 'test-agent',
      taskDescription: 'test-task',
      redirectUrl: 'http://localhost:3000/authenticated'
    });

    await page.goto(url);
    await expect(page.locator('header')).toContainText(`User is logged in ${userId}`);
  });
});

// Testing with custom client

const client = createClerkClient({
  apiUrl: 'https://...';,
  secretKey: process.env.CLERK_SECRET_KEY!,
});

const { url } = await createAgentTestingTask({
  clerkClient: client,
  onBehalfOf: {
    userId: process.env.CLERK_TEST_USER_ID!,
  },
  permissions: '*',
  agentName: 'test-agent',
  taskDescription: 'test-task',
  redirectUrl: 'http://localhost:3000/authenticated'
});

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • [] (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features
    • Added experimental Agent Tokens API to create agent tokens for automated user impersonation flows. Supports session duration and redirect URL options.
    • Agent token responses now include token value, status (pending|accepted|revoked), associated user, URL, and timestamps (created/updated).

@tmilewski tmilewski self-assigned this Feb 5, 2026
@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 8ee2671

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@clerk/backend Minor
@clerk/testing Minor
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Feb 19, 2026 9:35pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7783

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7783

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7783

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7783

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7783

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7783

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@7783

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7783

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7783

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7783

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@7783

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7783

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7783

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7783

@clerk/react

npm i https://pkg.pr.new/@clerk/react@7783

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7783

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7783

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7783

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7783

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7783

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7783

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7783

commit: 8ee2671

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds Agent Tasks support across the backend and testing packages. Introduces a new AgentTaskAPI with create and revoke methods and registers it on the backend API client as agentTasks. Adds an AgentTask resource model, AgentTaskJSON type, and deserialization for ObjectType.AgentTask. Exposes the endpoint via endpoints index and top-level backend exports. Adds tests for request/response mapping. Testing packages gain a createAgentTestingTask helper with Playwright and Cypress adapters and accompanying changesets.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main changes: adding agent tasks API endpoints to the backend package and helpers to the testing package.
Linked Issues check ✅ Passed The PR implements agent task API endpoints and testing helpers that enable creating agent tasks to act on behalf of users, addressing the core requirement from USER-4622.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing agent tasks support: API endpoints, resource models, deserialization logic, testing helpers, and associated exports are all in scope.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

@tmilewski tmilewski changed the title feat(backend): Add test session tokens endpoints feat(backend): Add agent tokens endpoints Feb 6, 2026
coderabbitai[bot]

This comment was marked as resolved.

@tmilewski tmilewski force-pushed the tom/user-4622-implement-utt-backend-sdk-endpoints branch from f76dbf1 to cd47a4f Compare February 19, 2026 03:14
@tmilewski tmilewski changed the title feat(backend): Add agent tokens endpoints feat(backend,testing): Add agent tokens endpoints Feb 19, 2026
@tmilewski tmilewski changed the title feat(backend,testing): Add agent tokens endpoints feat(backend,testing): Add agent tokens endpoints & helpers Feb 19, 2026
@tmilewski tmilewski changed the title feat(backend,testing): Add agent tokens endpoints & helpers feat(backend,testing): Add agent tasks endpoints & helpers Feb 19, 2026
@tmilewski
Copy link
Member Author

@coderabbitai resume

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

✅ Actions performed

Reviews resumed.

Copy link
Member

@wobsoriano wobsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

@tmilewski tmilewski merged commit 3abe9ed into main Feb 20, 2026
45 checks passed
@tmilewski tmilewski deleted the tom/user-4622-implement-utt-backend-sdk-endpoints branch February 20, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments